package eu.news.interconnect;

import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;

public abstract class Entity implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3356016308297117099L;

	public abstract byte[] getSerializeBytes() throws IOException;

	public static final Entity rebuildEntity(byte[] bytes)
			throws IOException, ClassNotFoundException {
		Object entity = Utils.generateObject(bytes);
		if (entity instanceof Entity)
			return (Entity) entity;
		return null;
	}

	public static final Entity rebuildEntity(InputStream in)
			throws IOException, ClassNotFoundException {
		Object entity = Utils.generateObject(in);
		if (entity instanceof Entity)
			return (Entity) entity;
		return null;
	}
}
